package com.musichord.core.track;

import java.util.List;
import java.util.Vector;

import javax.sound.midi.Track;

import com.musichord.core.event.ChordEvent;
import com.musichord.core.event.MCEvent;
import com.musichord.core.event.NoteEvent;
import com.musichord.core.helper.StringParser;
import com.musichord.core.unit.chord.Chord;
import com.musichord.core.unit.note.Note;

public class DefaultTrack extends MCTrack {

	public DefaultTrack(Track track) {
		super(track);
	}

	/* Add chords in the end of a track */
	public void addChords2Track(String chordString) {
		List<Chord> chordList = StringParser.ParseChords(chordString);
		List<MCEvent> eventList = new Vector<MCEvent>();
		for (Chord chord : chordList) {
			eventList.add(new ChordEvent(chord));
		}
		this.addMCEvents2Track(eventList);
	}

	/* Add notes in the end of a track */
	public void addNotes2Track(String noteString) {
		List<Note> noteList = StringParser.ParseNotes(noteString);
		List<MCEvent> eventList = new Vector<MCEvent>();
		for (Note note : noteList) {
			eventList.add(new NoteEvent(note));
		}
		this.addMCEvents2Track(eventList);
	}
}
